<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>
    <script>
      /**
       * @param {number[][]} matrix
       * @return {void} Do not return anything, modify matrix in-place instead.
       */
      var rotate = function (matrix) {
        const newArr = JSON.parse(JSON.stringify(matrix))
        let size = matrix.length
        for(let i = 0;i<newArr.length;i++) {
          let item = newArr[i]
          item.forEach((col,y)=>{
            matrix[y][size-1-i] = col
          })
        }
        return matrix;
      };
      let arr = [
        [1, 2, 3],
        [4, 5, 6],
        [7, 8, 9],
      ];
      let pre = [
        [7, 4, 1],
        [8, 5, 2],
        [9, 6, 3],
      ];
      let ss=rotate(arr);
      console.log(ss)

    </script>
  </body>
</html>
